'use strict';

module.exports = app => {
  const {
    INTEGER,
    STRING,
    DATE,
  } = app.Sequelize;
  const Productimg = app.model.define('productimg', {
    id: {
      type: INTEGER,
      allowNull: false,
      primaryKey: true,
      autoIncrement: true,
      comment: '序号',
    },
    sid: {
      type: INTEGER,
      comment: '所属商品',
    },
    imglist: {
      type: STRING,
      comment: '商品图片列表',
    },
    createdDate: {
      type: DATE,
      comment: '创建类型时间',
      field: 'createdDate',
    },
  }, {
    freezeTableName: true,
    timestamps: false, // 去除createAt updateAt
  });
  Productimg.associate = function() {
    app.model.Productimg.belongsTo(app.model.Productinfo, {
      foreignKey: 'sid',
      targetKey: 'id',
    });
  };
  return Productimg;
};
